﻿package Classes {
	
	import flash.display.MovieClip;
	import Asserts.ChessFrontRedIcon;
	import flash.display.Bitmap;
	import flash.display.BitmapData;
	import flash.text.TextField;
	import flash.text.TextFormat;
	import fl.motion.Color;
	
	public class Chess extends MovieClip {
		var chessFront:Bitmap;
		var chessBack:Bitmap;
		var _title:String="";
		var lableTitle:TextField = new TextField();
		public function Chess(side:int) {
			var txtFormat:TextFormat = new TextFormat();
			chessBack = new Bitmap();
			if(side == 0) {
				chessFront = new Bitmap();
				lableTitle.textColor = 0xFF0000
				chessFront.bitmapData = new Asserts.ChessFrontRedIcon(50,50);
				chessBack.bitmapData = new Asserts.ChessRedBack();

			}
			else {
				chessFront = new Bitmap();
				lableTitle.textColor = 0x0;
				chessFront.bitmapData = new Asserts.ChessFrontIcon();
				chessBack.bitmapData = new Asserts.ChessBack();
			}
			chessFront.width = 60;
			chessFront.height = 30;
			chessBack.width = 60;
			chessBack.height = 30;
			chessFront.x = 0;
			chessFront.y = 0;
			addChild(chessFront);
			
			txtFormat.size = 20;
			txtFormat.bold = true;
			lableTitle.defaultTextFormat = txtFormat;
			
			lableTitle.x = 7;
			lableTitle.y = 2;
			lableTitle.mouseEnabled = false;
			addChild(lableTitle);
			addChild(chessBack);
			chessBack.visible = false;
			
		}
		
		public function set backVisible(v:Boolean):void 
		{
			chessBack.visible = v;
		}
		
		public function get title():String
		{
			return _title;
		}
		
		public function setTitle(title:String):void 
		{
			lableTitle.text = title;
			_title = title;
		}
	}
	
}
